package com.ruoyi.myplayer.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.myplayer.domain.PlayerSinger;
import com.ruoyi.myplayer.service.IPlayerSingerService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 歌手信息Controller
 * 
 * @author ruoyi
 * @date 2025-04-10
 */
@RestController
@RequestMapping("/myplayer/singer")
public class PlayerSingerController extends BaseController
{
    @Autowired
    private IPlayerSingerService playerSingerService;

    /**
     * 查询歌手信息列表
     */
    @GetMapping("/list")
    public AjaxResult list(PlayerSinger playerSinger)
    {
        if (playerSinger.getLetterSort().equals("热")){
            playerSinger.setLetterSort(null);
        }

        if (playerSinger.getSex().toString().equals("-1")){
            playerSinger.setSex(null);
        }
        if (playerSinger.getType().toString().equals("-1")){
            playerSinger.setType(null);
        }
        List<PlayerSinger> list = playerSingerService.selectPlayerSingerList(playerSinger);
        return AjaxResult.success(list);
    }

    /**
     * 获取歌手信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('myplayer:singer:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(playerSingerService.selectPlayerSingerById(id));
    }

    /**
     * 新增歌手信息
     */
    @PreAuthorize("@ss.hasPermi('myplayer:singer:add')")
    @Log(title = "歌手信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PlayerSinger playerSinger)
    {
        return toAjax(playerSingerService.insertPlayerSinger(playerSinger));
    }

    /**
     * 修改歌手信息
     */
    @PreAuthorize("@ss.hasPermi('myplayer:singer:edit')")
    @Log(title = "歌手信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PlayerSinger playerSinger)
    {
        return toAjax(playerSingerService.updatePlayerSinger(playerSinger));
    }

    /**
     * 删除歌手信息
     */
    @PreAuthorize("@ss.hasPermi('myplayer:singer:remove')")
    @Log(title = "歌手信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(playerSingerService.deletePlayerSingerByIds(ids));
    }
}
